<template>
  <tr class="bg-bg-3">
    <CheckboxCell
      v-if="isShowCheckbox"
      :is-checkbox-checked="record.isChecked"
      @on-click-checkbox="() => handleOnClickCheckbox?.(record.rowData)"
    />
    <BaseTableCell v-for="col in rowConfig" :cell-config="col" :record="record.rowData" />
  </tr>
</template>

<script setup lang="ts">
import { TABLE_CONTEXT } from "../config";
import { TableColumn, TableRow } from "../types";
import BaseTableCell from "./BaseTableCell.vue";
import CheckboxCell from "./CheckboxCell.vue";

const { record, rowConfig } = defineProps<{
  /**
   * @description 当前行的每个单元格配置信息
   */
  rowConfig: TableColumn[];

  /**
   * @description 当前行的数据信息
   */
  record: TableRow;
}>();

const { isShowCheckbox, handleOnClickCheckbox } = inject(TABLE_CONTEXT) ?? {};
</script>

<style scoped></style>
